//
//  ZFK_slideTableViewCell.m
//  Drops
//
//  Created by SHG on 16/6/1.
//  Copyright © 2016年 Drops.er. All rights reserved.
//

#import "ZFK_slideTableViewCell.h"

#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height

@implementation ZFK_slideTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    
    self.baseView = [[UIView alloc] init];
    self.baseView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.baseView];
    
    self.image = [[UIImageView alloc] init];
    self.image.backgroundColor = [UIColor lightGrayColor];
    [self.baseView addSubview:self.image];
    
    self.titleLabel = [[UILabel alloc] init];
//    self.titleLabel.backgroundColor = [UIColor redColor];
    [self.image addSubview:self.titleLabel];
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    self.titleLabel.textColor = [UIColor whiteColor];
    
    self.userView = [[UIView alloc] init];
//    self.userView.backgroundColor = [UIColor yellowColor];
    [self.baseView addSubview:self.userView];
    
    self.userImage = [[UIImageView alloc] init];
    self.userImage.backgroundColor = [UIColor lightGrayColor];
    [self.userView addSubview:self.userImage];
    
    self.userName = [[UILabel alloc] init];
//    self.userName.backgroundColor = [UIColor greenColor];
    [self.userView addSubview:self.userName];
    
    self.text = [[UILabel alloc] init];
//    self.text.backgroundColor = [UIColor redColor];
    [self.baseView addSubview:self.text];
    self.text.numberOfLines = 0;
    [self.text sizeToFit];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.baseView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.image.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.width / 3 * 2);
    self.titleLabel.frame = CGRectMake(10, self.image.frame.size.height / 6 * 5, WIDTH - 20, self.image.frame.size.height / 7);
    self.userView.frame = CGRectMake(0, self.image.frame.size.height, WIDTH, self.titleLabel.frame.size.height * 3 / 2);
    self.userImage.frame = CGRectMake(5, 5, self.userView.frame.size.height - 10, self.userView.frame.size.height - 10);
    self.userImage.layer.cornerRadius = (self.userView.frame.size.height - 10) / 2;
    self.userImage.layer.masksToBounds = YES;
    self.userName.frame = CGRectMake(self.userView.frame.size.height - 10 + 15, (self.userView.frame.size.height - 10) / 3, self.userView.frame.size.width / 2, (self.userView.frame.size.height - 10) / 2);
//    self.text.font = [UIFont systemFontOfSize:15];
//    NSLog(@"%lf",(self.text.text.length/(self.contentView.frame.size.width / 15)) * 15);
    self.text.frame = CGRectMake(5, self.image.frame.size.height + self.userView.frame.size.height + 5, WIDTH - 10, self.baseView.frame.size.height - self.image.frame.size.height - self.userView.frame.size.height);

}

@end
